home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / zdosio.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.6 KB  |  111 lines

  1. /* Copyright (C) 1992, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: zdosio.c,v 1.2 2000/09/19 19:00:53 lpd Exp $ */
  20. /* MS-DOS direct I/O operators. */
  21. /* These should NEVER be included in a released configuration! */
  22. #include "dos_.h"
  23. #include "ghost.h"
  24. #include "oper.h"
  25. #include "store.h"
  26.  
  27. /* <port> .inport <word> */
  28. private int
  29. zinport(i_ctx_t *i_ctx_p)
  30. {
  31.     os_ptr op = osp;
  32.  
  33.     check_type(*op, t_integer);
  34.     make_int(op, inport((int)op->value.intval));
  35.     return 0;
  36. }
  37.  
  38. /* <port> .inportb <byte> */
  39. private int
  40. zinportb(i_ctx_t *i_ctx_p)
  41. {
  42.     os_ptr op = osp;
  43.  
  44.     check_type(*op, t_integer);
  45.     make_int(op, inportb((int)op->value.intval));
  46.     return 0;
  47. }
  48.  
  49. /* <port> <word> .outport - */
  50. private int
  51. zoutport(i_ctx_t *i_ctx_p)
  52. {
  53.     os_ptr op = osp;
  54.  
  55.     check_type(*op, t_integer);
  56.     check_type(op[-1], t_integer);
  57.     outport((int)op[-1].value.intval, (int)op->value.intval);
  58.     pop(1);
  59.     return 0;
  60. }
  61.  
  62. /* <port> <byte> .outportb - */
  63. private int
  64. zoutportb(i_ctx_t *i_ctx_p)
  65. {
  66.     os_ptr op = osp;
  67.  
  68.     check_type(*op, t_integer);
  69.     check_int_leu(op[-1], 0xff);
  70.     outportb((int)op[-1].value.intval, (byte) op->value.intval);
  71.     pop(1);
  72.     return 0;
  73. }
  74.  
  75. /* <loc> .peek <byte> */
  76. private int
  77. zpeek(i_ctx_t *i_ctx_p)
  78. {
  79.     os_ptr op = osp;
  80.  
  81.     check_type(*op, t_integer);
  82.     make_int(op, *(byte *) (op->value.intval));
  83.     return 0;
  84. }
  85.  
  86. /* <loc> <byte> .poke - */
  87. private int
  88. zpoke(i_ctx_t *i_ctx_p)
  89. {
  90.     os_ptr op = osp;
  91.  
  92.     check_type(*op, t_integer);
  93.     check_int_leu(op[-1], 0xff);
  94.     *(byte *) (op[-1].value.intval) = (byte) op->value.intval;
  95.     pop(1);
  96.     return 0;
  97. }
  98.  
  99. /* ------ Operator initialization ------ */
  100.  
  101. const op_def zdosio_op_defs[] =
  102. {
  103.     {"1.inport", zinport},
  104.     {"1.inportb", zinportb},
  105.     {"2.outport", zoutport},
  106.     {"2.outportb", zoutportb},
  107.     {"1.peek", zpeek},
  108.     {"2.poke", zpoke},
  109.     op_def_end(0)
  110. };
  111.